*Further Test - Tariff Imports / Tradeflows / Deforestation

clear
eststo clear

*cd "~/Dropbox/Donor Adjustment/Replication/"
use "CombinedData.dta", clear

order WDI_Name id year
xtset id year

*** DATA MANIPULATION

gen log_SO2 = log(SO2+1)
label var log_SO2 "log (SO2)"
replace CO2=0 if CO2 < 0
gen log_CO2 = log(CO2+1)
label var log_CO2 "log (CO2)"
gen log_BOD = log(BOD)
label var log_BOD "log (BOD)"
gen log_gdp = log(gdp)
gen log_PM10 = log(pm10)
label var log_PM10 "log (PM10)"
label var log_gdp "log (GDP)" 
gen log_gdp_pc = log(gdp_pc)
label var log_gdp_pc "log (GDP p.c.)"
gen pop = gdp/gdp_pc
gen log_pop = log(pop)
label var log_pop "log (Population)"
label var polity2 "Polity"
gen time = year-1960
gen time2 = time^2
gen time3 = time^3
gen wto_polity2 = wto * polity2
encode(region), gen(region_id)

gen log_deforest=log(deforest+1)

gen envmin=env_ministry_real
by id (year), sort: replace envmin =. if envmin[_n-1]== 1 
by id (year), sort: replace envmin =. if envmin== 1 & envmin[_n-1]==.

gen FIT1=FIT
by id (year), sort: replace FIT1 =. if FIT1[_n-1]== 1 
by id (year), sort: replace FIT1 =. if FIT1== 1 & FIT1[_n-1]==.
replace FIT1=1 if id==72 & year==1990

*** DYNAMIC MODEL FOR POLLUTION

gen L1log_SO2=L1.log_SO2
label var L1log_SO2 "log(SO2) (t-1)" 
gen L1log_CO2=L1.log_CO2
label var L1log_CO2 "log(CO2) (t-1)"
gen L1log_BOD=L1.log_BOD
label var L1log_BOD "log(BOD) (t-1)"
gen L1log_PM10=L1.log_PM10
label var L1log_PM10 "log(PM10) (t-1)"

gen L1gatt_wto=L1.gatt_wto
label var L1gatt_wto "GATT/WTO Membership (t-1)"
gen L1log_gdp_pc=L1.log_gdp_pc
label var L1log_gdp_pc "log(GDP p.c) (t-1)"
gen L1log_pop=L1.log_pop
label var L1log_pop "log(population) (t-1)"
gen L1life_expectancy=L1.life_expectancy
label var L1life_expectancy "Life expectancy (t-1)"
label var life_expectancy "Life expectancy"
gen L1polity2=L1.polity2
label var L1polity2 "Polity (t-1)"
gen L1log_environment=L1.log_environment
label var L1log_environment "log(Environmental Aid) (t-1)"
gen L1log_neutral=L1.log_neutral
label var L1log_neutral "log(Neutral Aid) (t-1)"
gen L1log_dirty=L1.log_dirty
label var L1log_dirty "log(Dirty Aid) (t-1)"
label var urban_pop_per "Urban Population $\%$" 
gen L1urban_pop_per=L1.urban_pop_per
label var L1urban_pop_per "Urban Population $\%$ (t-1)"
gen L1electricity_coal_production=L1.electricity_coal_production 
label var L1electricity_coal_production "Electricity from Coal $\%$ (t-1)" 
label var electricity_coal_production "Electricity from Coal"
gen L1electricity_production_renew=L1.electricity_production_renew
label var L1electricity_production_renew "Electricity from Renewable Energy $\%$ (t-1)" 
label var electricity_production_renew "Electricity from Renewables"
gen L1wto=L1.wto
label var L1wto "WTO Membership (t-1)"
label var wto "WTO Membership"

gen L1gatt_wto_informal=L1.gatt_wto_informal
label var L1gatt_wto_informal "GATT/WTO Informal Standing (t-1)"
label var gatt_wto_informal "GATT/WTO Informal Standing"

egen PTA = rowtotal(USPTA JapanPTA EFTAPTA EUPTA)

gen post_tokyo = 0 
replace post_tokyo = 1 if year > 1979
label var post_tokyo "Post-Tokyo Round"

gen post_uruguay = 0 
replace post_uruguay = 1 if year > 1994
label var post_uruguay "Post-Uruguay Round"

gen L1post_tokyo_gatt_wto = L1gatt_wto * L1.post_tokyo
label var L1post_tokyo_gatt_wto "GATT/WTO Membership * Post-Tokyo (t-1)"

gen post_tokyo_gatt_wto = gatt_wto * post_tokyo
label var post_tokyo_gatt_wto "GATT/WTO Membership * Post-Tokyo"

gen L1post_uruguay_gatt_wto = L1gatt_wto * L1.post_uruguay
label var L1post_uruguay_gatt_wto "GATT/WTO Memberhsip * Post-Uruguay (t-1)"

gen post_uruguay_gatt_wto = gatt_wto * post_uruguay
label var post_uruguay_gatt_wto "GATT/WTO Memberhsip * Post-Uruguay"

gen L1auto_emissions_reg=L1.auto_emissions_reg
label var L1auto_emissions_reg "Auto Emission Standards (t-1)"

gen wtoexportshare=totalsharewto*wto
gen gatt_wtoexportshare=totalsharegatt_wto*gatt_wto

gen L1totalsharewto=L1.totalsharewto
gen L1totalsharegatt_wto=L1.totalsharegatt_wto

gen L1wtoexportshare=L1.wtoexportshare
gen L1gatt_wtoexportshare=L1.gatt_wtoexportshare

label var totalsharewto "Export share to WTO"
label var totalsharegatt_wto "Export share to GATT/WTO"
label var L1totalsharewto "Export share to WTO (t-1)"
label var L1totalsharegatt_wto "Export share to GATT/WTO (t-1)"

label var wtoexportshare "WTO * Export share to WTO"
label var gatt_wtoexportshare "GATT/WTO * Export share to GATT/WTO"
label var L1wtoexportshare "WTO * Export share to WTO (t-1)"
label var L1gatt_wtoexportshare "GATT/WTO * Export share to GATT/WTO (t-1)"

gen importsvalue_pc=importsvaluein1000usd_ahs/ population

gen subgroup=0 
replace subgroup=1 if importsvalue_pc~=. & gatt_wto==0

gen L1subgroup=L1.subgroup
replace subgroup=1 if L1subgroup==1
replace subgroup=1 if L2.subgroup==1
replace subgroup=1 if L1subgroup==1

*cd "~/Dropbox/Donor Adjustment/Replication/check"

*Figure A1: Box Plot of Average Tariffs on Environmental Goods over WTO Membership (upper panel); Box Plot of Imports Value of Environmental Goods over WTO Membership (lower panel).
graph box averagetariffenv if subgroup==1, by(gatt_wto)
graph box importsvalue_pc if subgroup==1, by(gatt_wto)

ttest averagetariffenv if subgroup==1, by(gatt_wto)
ttest importsvalue_pc if subgroup==1, by(gatt_wto)


*Table A105: Estimating the Impact of GATT/WTO on Environmental Tariffs and Imports Value
eststo clear
eststo: regress averagetariffenv gatt_wto time time2 time3 if subgroup==1, robust
eststo: regress averagetariffenv gatt_wto polity2 log_gdp_pc log_pop time time2 time3 if subgroup==1, robust
eststo: regress averagetariffenv gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per time time2 time3 if subgroup==1, robust
eststo: regress importsvalue_pc gatt_wto time time2 time3 if subgroup==1, robust
eststo: regress importsvalue_pc gatt_wto polity2 log_gdp_pc log_pop time time2 time3 if subgroup==1, robust
eststo: regress importsvalue_pc gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per time time2 time3 if subgroup==1, robust
*esttab using "TariffImports.tex", booktabs label title(Estimating the Impact of GATT/WTO on Environmental Tariffs and Imports Value \label{tariff}) keep (gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) mtitles ("" "" "" "" "" "")  stats(N, labels(Observations) fmt(0 0)) indicate("Time Trend=time") nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps



*** Tradeflows

gen dirimport = hs25import + hs26import + hs27import + hs28import + hs29import + hs47import + hs48import + hs72import + hs73import + hs74import + hs75import + hs76import + hs78import + hs79import + hs80import + hs81import
gen direxport = hs25export + hs26export + hs27export + hs28export + hs29export + hs47export + hs48export + hs72export + hs73export + hs74export + hs75export + hs76export + hs78export + hs79export + hs80export + hs81export

replace dirimport=dirimport/GDPdeflator
replace direxport=direxport/GDPdeflator

gen log_dirimport = log(dirimport+1)
label var log_dirimport "log (dirimport)"
gen log_direxport = log(direxport+1)
label var log_direxport "log (direxport)"

gen L1log_dirimport=L1.log_dirimport
label var L1log_dirimport "log(dirimport) (t-1)" 
gen L1log_direxport=L1.log_direxport
label var L1log_direxport "log(direxport) (t-1)"


set more 1
*Table A106: Difference in Difference: Estimating the Impact of GATT/WTO on Trade Flow
eststo clear
eststo: xi: xtreg log_dirimport gatt_wto i.year  ,  fe robust
eststo: xi: xtreg log_dirimport gatt_wto polity2 log_gdp_pc log_pop i.year  ,  fe robust
eststo: xi: xtreg log_dirimport gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year  ,  fe robust
eststo: xi: xtreg log_direxport gatt_wto i.year  ,  fe robust
eststo: xi: xtreg log_direxport gatt_wto polity2 log_gdp_pc log_pop i.year  ,  fe robust
eststo: xi: xtreg log_direxport gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year  ,  fe robust
*esttab using "Tradeflow(did)_dir.tex", booktabs label title(Difference in Difference: Estimating the Impact of GATT/WTO on Trade Flow \label{tradeflow(DID)}) keep(gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("" "" "" "" "" "")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*"  ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*Table A107: Dynamic Model: Estimating the Impact of GATT/WTO on Trade Flow
eststo clear
eststo: xi: xtreg log_dirimport L1log_dirimport L1gatt_wto i.year i.region, robust 
eststo: xi: xtreg log_dirimport L1log_dirimport L1gatt_wto L1polity2 L1log_gdp_pc L1log_pop  i.year i.region, robust
eststo: xi: xtreg log_dirimport L1log_dirimport L1gatt_wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per i.year i.region, robust
eststo: xi: xtreg log_direxport L1log_direxport L1gatt_wto i.year i.region , robust
eststo: xi: xtreg log_direxport L1log_direxport L1gatt_wto L1polity2 L1log_gdp_pc L1log_pop  i.year i.region, robust
eststo: xi: xtreg log_direxport L1log_direxport L1gatt_wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per i.year i.region, robust
*esttab using "Tradeflow(dynamic)_dir.tex", booktabs label title(Dynamic Model: Estimating the Impact of GATT/WTO on Trade Flow \label{tradeflow(Dynamic)}) keep (L1log_dirimport L1log_direxport L1gatt_wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per) order (L1gatt_wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per L1log_SO2 L1log_CO2 )  mtitles ("" "" "" "" "" "")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*" "Region FE=_Iregion_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

*Table A108: Difference in Difference: Estimating the Impact of WTO on Trade Flow after 1995
eststo clear
eststo: xi: xtreg log_dirimport wto i.year  ,  fe robust
eststo: xi: xtreg log_dirimport wto polity2 log_gdp_pc log_pop i.year  ,  fe robust
eststo: xi: xtreg log_dirimport wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year  ,  fe robust
eststo: xi: xtreg log_direxport wto i.year  ,  fe robust
eststo: xi: xtreg log_direxport wto polity2 log_gdp_pc log_pop i.year  ,  fe robust
eststo: xi: xtreg log_direxport wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year  ,  fe robust
*esttab using "Tradeflow(did)WTO_dir.tex", booktabs label title(Difference in Difference: Estimating the Impact of WTO on Trade Flow after 1995 \label{tradeflowwto(DID)}) keep(wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("" "" "" "" "" "")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*"  ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps


*Table A109: Dynamic Model: Estimating the Impact of WTO on Trade Flow after 1995
eststo clear
eststo: xi: xtreg log_dirimport L1log_dirimport L1wto i.year i.region, robust 
eststo: xi: xtreg log_dirimport L1log_dirimport L1wto L1polity2 L1log_gdp_pc L1log_pop  i.year i.region, robust
eststo: xi: xtreg log_dirimport L1log_dirimport L1wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per i.year i.region, robust
eststo: xi: xtreg log_direxport L1log_direxport L1wto i.year i.region , robust
eststo: xi: xtreg log_direxport L1log_direxport L1wto L1polity2 L1log_gdp_pc L1log_pop  i.year i.region, robust
eststo: xi: xtreg log_direxport L1log_direxport L1wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per i.year i.region, robust
*esttab using "Tradeflow(dynamic)WTO_dir.tex", booktabs label title(Dynamic Model: Estimating the Impact of WTO on Trade Flow after 1995 \label{tradeflowwto(Dynamic)}) keep (L1log_dirimport L1log_direxport L1wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per) order (L1wto L1polity2 L1log_gdp_pc L1log_pop L1life_expectancy L1urban_pop_per L1log_SO2 L1log_CO2 )  mtitles ("" "" "" "" "" "")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*" "Region FE=_Iregion_*" ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps


*** Deforestation

*Table A110: Difference in Difference: Estimating the Impact of GATT/WTO on Deforestation
set more 1
eststo clear
eststo: xi: xtreg log_deforest gatt_wto i.year,  fe robust
eststo: xi: xtreg log_deforest gatt_wto polity2 log_gdp_pc log_pop i.year,  fe robust
eststo: xi: xtreg log_deforest gatt_wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year,  fe robust
eststo: xi: xtreg log_deforest wto i.year ,  fe robust
eststo: xi: xtreg log_deforest wto polity2 log_gdp_pc log_pop i.year  ,  fe robust
eststo: xi: xtreg log_deforest wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per i.year  ,  fe robust
*esttab using "Deforestation(did).tex", booktabs label title(Difference in Difference: Estimating the Impact of GATT/WTO on Deforestation \label{deforest(DID)}) keep(gatt_wto wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per) order (gatt_wto wto polity2 log_gdp_pc log_pop life_expectancy urban_pop_per)  mtitles ("" "" "" "" "" "")  stats(N_g N, labels(Countries Observations) fmt(0 0)) indicate("Year FE=_Iyear_*"  ) nodepvars se(3) b(3) replace star(* 0.10 ** 0.05 *** 0.01) compress nogaps

